!function () {
    $('.btn-form').on('click', function () {
        var username = $('.yonghuming').val(),
            youxiang = $('.youxiang').val(),
            mima = $('.mima').val(),
            againmima = $('.againmima').val(),
            mobileNum = $('.mobileNum').val(),
            question = $('.question').val(),
            qanswer = $('.qanswer').val(),
            yzm = $('.yzm').val();
        if (username.length < 3) {
            $('#yz1').show()
            return
        } else {
            $('#yz1').hide()
        }
        if (youxiang == '') {
            $('#yz2').show()
            return
        } else {
            $('#yz2').hide()
        }
        if (mima.length < 6) {
            $('#yz3').show()
            return
        } else {
            $('#yz3').hide()
        }
        if (againmima != mima) {
            $('#yz4').show()
            return
        } else {
            $('#yz4').hide()
        }
        $.ajax({
            type: 'post',
            url: 'http://localhost/ryw/api.php/rywusers',
            data: {
                loginName: username,
                email: youxiang,
                loginKey: mima,
                mobile: mobileNum,
                question: question,
                answer: qanswer
            },
            success: function (res) {
                alert('注册成功！');
                $('input').val("")
                $('.question').val("")
                if(res){
                    window.location.href = '../html/login.html'
                }
                localStorage.setItem('zxwx-rywusers',username)
            }
        })
    })
}()